//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<IEntityImplAttr.h>
///	@path	~/src/scene/
///	@date	2007/11/02
///	@desc	Entity with implementation of attribute management.

#pragma once

#include "xeres.h"

#include "scene/IEntity.h"

#include <map>

namespace xeres {

	/*!
		\class	IEntityImplAttr
		\brief
	*/
	class IEntityImplAttr : public IEntity
	{
	public:

		/// \ctor
		IEntityImplAttr( void );

		/// \dtor
		virtual ~IEntityImplAttr( void );

		DECL_IOBJECT_INTERFACE( IEntityImplAttr , IEntity );

		/*!
			\brief		Get entity's attribute.
						Attribute must be registered before using.
		*/
		virtual RefWeak<IAttribute> GetAttribute( int attributeID );

	protected:

		// local methods

		// entity attributes, for children use

		// get attribute
		RefWeak<IAttribute> ImplGetAttribute( int attributeID );

		// exist attribute
		bool ImplExistAttribute( int attributeID );

		// set attribute (failed when attribute exists)
		bool ImplSetAttribute( int attributeID , RefWeak<IAttribute> attr );

		// replace attribute (failed when attribute not exists)
		bool ImplReplaceAttribute( int attributeID , RefWeak<IAttribute> attr );

	private:

		typedef std::map< int , Ref<IAttribute> > AttributeMap;

		AttributeMap		m_attrMap;
	};

} // namespace xeres
